/*
 * 	Author : Pallab
 * 	Prog: E2.cxx
 *
 * 	Created on: 06:21:42 AM - 2013:2:23
 * "I have not failed, I have just found 10000 ways that won't work."
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i,frm,upto) for( int i=(frm),_i=(upto);(i) < (_i) ; ++i )
#define foD(i,frm,upto) for( int i=(frm),_i=(upto);(i) >= (_i) ; --i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define Int int
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define dbg(...)       printf(__VA_ARGS__)
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait ( double seconds ) {
    double endtime = clock() + ( seconds * CLOCKS_PER_SEC );
    while ( clock() < endtime ) {
        ;
    }
}
template<class T>
    inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while ( c<33 ) c=getchar();
    while ( c>33 ) {
        if ( c=='-' ) {
            neg=true;
        } else {
            a= ( a*10 ) + ( c-'0' );
        }
        c=getchar();
    }
    return neg?-a:a;
}
Int const mod=1000000007LL;
inline Int domod ( Int val ) {
    val%=mod;
    if ( val<0 ) val+=mod;
    return val;
}
Int dp[405][ ( 1<<12 )];
int N,K;
inline void read() {
    N=fastIn<int>(),K=fastIn<int>();
}
inline bool isP ( int const &msk ,int const &a,int const &b ) {
    for ( int i=a,j=b; i<=j; ++i,--j ) {
        bool f1 = msk& ( 1<<i ),f2=msk& ( 1<<j );
        if ( f1!=f2 ) return false;
    }
    return true;
}
Int go ( int at,int msk ) {
    if ( at>=K && ( isP ( msk,0,K-1 ) ) ) return 0LL;
    if ( at>=N ) {
        return 1LL;
    }
    Int &d = dp[at][msk];
    if ( d!=-1 ) return d;
    d=0LL;
    if ( at>=K ) {
        int lst=msk& ( 1<< ( K-1 ) );
        if ( lst ) {
            int nxtMsk = msk^ ( 1<< ( K-1 ) ); //make least bit 0
            nxtMsk<<=1; //now shft it
            d = domod ( d+go ( at+1,nxtMsk ) );
            if ( !isP ( msk,0,K-2 ) ) {
                d=domod ( d+go ( at+1,nxtMsk|1 ) ) ;
            }
        } else {
            int nxtMsk = (msk<<1);
            d=domod ( d+go ( at+1,nxtMsk|1 ) );
            if ( !isP ( msk,0,K-2 ) ) {
                d=domod ( d+go ( at+1,nxtMsk ) );
            }
        }
    } else {
        int nmsk=(msk<<1);
        d=domod ( d+go ( at+1, nmsk) ) ;
        d=domod ( d+go ( at+1, nmsk|1) ) ;
    }

    return d;
}

inline void proc() {
    SET ( dp,-1 );
    cout<<go ( 0,0 ) <<'\n';
}


int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if ( !freopen ( "in1", "r", stdin ) )
        puts ( "error opening file in " ), assert ( 0 );
    kase = 1;
#endif
    kase=fastIn<int>();
    foR ( i,0,kase ) {
        read();
        proc();
    }
    return 0;
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 
